package com.tjetc.controller;

import com.tjetc.common.JsonResult;
import com.tjetc.entity.FoodRecord;
import com.tjetc.entity.GoodsRecord;
import com.tjetc.service.FoodRecordService;
import com.tjetc.service.GoodsRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("goodsrecord")
public class GoodsRecordController {
    @Autowired
    private GoodsRecordService goodsRecordService;

    @RequestMapping("detail/{operationId}")
    public JsonResult detail(@PathVariable("operationId") Long id) {
        return goodsRecordService.findById(id);
    }
    @RequestMapping("pagegoods")
    public JsonResult pagegoods(@RequestParam(value = "name", required = false,defaultValue = "") String name,
                                @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                                @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return goodsRecordService.findGoodsPage(name,pageNo,pageSize);
    }
    @RequestMapping("pageemployee")
    public JsonResult pageemployee(@RequestParam(value = "name", required = false,defaultValue = "") String name,
                                    @RequestParam(value = "pageNo",required = false,defaultValue = "1") Integer pageNo,
                                    @RequestParam(value = "pageSize",required = false,defaultValue = "2") Integer pageSize) {
        return goodsRecordService.findEmployeePage(name,pageNo,pageSize);
    }
    @RequestMapping("delete/{operationId}")
    public JsonResult delete(@PathVariable("operationId") Long id) {
        return goodsRecordService.deleteById(id);
    }
    //接收参数格式是json
    @RequestMapping("save")
    public JsonResult save(@RequestBody GoodsRecord goodsRecord){
        return goodsRecordService.save(goodsRecord);
    }
}
